<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">

<head>
    <title>首页</title>
    <th:block th:replace="/backstage/common_resources::common_css"></th:block>
    <th:block th:replace="/backstage/common_resources::common_js"></th:block>
</head>

<body class="hold-transition skin-purple sidebar-mini">

<header th:replace="~{/backstage/common_header::header}"></header>
<aside th:replace="~{/backstage/common_aside::aside}"></aside>

    <div class="wrapper">
        <div class="content-wrapper">
            <div class="tab-content">
                <form action="/backstage/message/add" method="post">
                    <div style="padding: 10px;display: flex">
                        <textarea name="message" style="width: 95%;height: 100px" value="无"></textarea>
                        <input id="time" type="hidden" name="time" >
                        <button type="submit" class="btn btn-info">发布</button>
                        <script>
                            $(function () {
                                function getNowDateTime(){
                                    var now = new Date();
                                    var year = now.getFullYear();
                                    var month = (now.getMonth() + 1) < 10 ? '0' + (now.getMonth() + 1) : now.getMonth() + 1;
                                    var dates = now.getDate() < 10 ? '0' + now.getDate() : now.getDate();
                                    var hours = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
                                    var minutes = now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes();
                                    var seconds = now.getSeconds() < 10 ? '0' + now.getSeconds() : now.getSeconds();
                                    return year + "/" + month + "/" + dates + " " + hours + ":" + minutes + ":" + seconds;
                                }
                                var a=getNowDateTime();
                                $('#time').val(a);
                            })
                        </script>
                    </div>
                </form>
                <div class="active tab-pane" id="activity" style="padding: 10px;max-height: 400px;overflow:auto">
                    <!-- Post -->
                    <div class="post" th:each="message:${allMessage}" style="background-color:whitesmoke;border: 1px solid grey;padding: 10px;margin-bottom: 0;">
                        <div class="user-block" style="display: flex;justify-content: space-between">

                          <div style="width: 97%;">
                              <span  th:text="${message.users.name}" style="color: #00c0ef;margin-right: 15px"></span>
                              <span  th:text="${message.time}"></span>
                          </div>
                          <a th:href="@{/backstage/message/delete(mid=${message.mid})}"  sec:authorize="hasAnyAuthority('/boss')" class="pull-right btn-box-tool" ><i class="fa fa-times"></i></a>


                        </div>
                        <!-- /.user-block -->
                        <p th:text="${message.message}"></p>

                    </div>


                    <!-- /.post -->


                </div>



                <!-- /.tab-pane -->
            </div>
        </div>
    </div>

<footer th:replace="/backstage/common_footer::footer"></footer>
</body>

</html>